#!/bin/bash

DIRECTORY="$(dirname "$(dirname "$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )")")"

function error {
  echo -e "\\e[91m$1\\e[39m"
  exit 1
}

echo "Removing dependencies..."
"${DIRECTORY}/purge-installed" "$(dirname "$0")" || exit 1

echo "Removing $HOME/wor-flasher folder..."
rm -rf ~/wor-flasher || sudo rm -rf ~/wor-flasher || error "Failed to remove ~/wor-flasher folder!"

echo "Removing menu button..."
rm -f ~/.local/share/applications/wor-flasher.desktop

if [ -d ~/wor-flasher-files ];then
  echo -e "\nDuring use, WoR-flasher downloads all files to $HOME/wor-flasher-files\nThis folder exists right now.\nFeel free to delete that folder to save disk space.\n"
fi
